export function loadScript({ key, version }) {
  return new Promise(resolve => {
    if (!window.T) {
      const script = document.createElement('script');
      script.setAttribute(
        'src',
        `${window.location.protocol}//api.tianditu.gov.cn/api?v=${version}&tk=${key}`,
      );
      document.head.appendChild(script);
      script.onload = () => {
        resolve();
      };
    }
  });
}
